/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author DangThanh
 */
@Entity
@Table(name = "News", catalog = "MailServerDB", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "News.findAll", query = "SELECT n FROM News n"),
    @NamedQuery(name = "News.findByNewId", query = "SELECT n FROM News n WHERE n.newId = :newId"),
    @NamedQuery(name = "News.findByNewSubject", query = "SELECT n FROM News n WHERE n.newSubject = :newSubject"),
    @NamedQuery(name = "News.findByPublisher", query = "SELECT n FROM News n WHERE n.publisher = :publisher"),
    @NamedQuery(name = "News.findByImageThumb", query = "SELECT n FROM News n WHERE n.imageThumb = :imageThumb")})
public class News implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "new_id", nullable = false)
    private Integer newId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "new_subject", nullable = false, length = 255)
    private String newSubject;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 2147483647)
    @Column(name = "new_body", nullable = false, length = 2147483647)
    private String newBody;
    @Basic(optional = false)
    @NotNull
    @Column(name = "publisher", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date publisher;
    @Size(max = 255)
    @Column(name = "image_thumb", length = 255)
    private String imageThumb;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
    @ManyToOne(optional = false)
    private Users userId;

    public News() {
    }

    public News(Integer newId) {
        this.newId = newId;
    }

    public News(Integer newId, String newSubject, String newBody, Date publisher) {
        this.newId = newId;
        this.newSubject = newSubject;
        this.newBody = newBody;
        this.publisher = publisher;
    }

    public Integer getNewId() {
        return newId;
    }

    public void setNewId(Integer newId) {
        this.newId = newId;
    }

    public String getNewSubject() {
        return newSubject;
    }

    public void setNewSubject(String newSubject) {
        this.newSubject = newSubject;
    }

    public String getNewBody() {
        return newBody;
    }

    public void setNewBody(String newBody) {
        this.newBody = newBody;
    }

    public Date getPublisher() {
        return publisher;
    }

    public void setPublisher(Date publisher) {
        this.publisher = publisher;
    }

    public String getImageThumb() {
        return imageThumb;
    }

    public void setImageThumb(String imageThumb) {
        this.imageThumb = imageThumb;
    }

    public Users getUserId() {
        return userId;
    }

    public void setUserId(Users userId) {
        this.userId = userId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (newId != null ? newId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof News)) {
            return false;
        }
        News other = (News) object;
        if ((this.newId == null && other.newId != null) || (this.newId != null && !this.newId.equals(other.newId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.entity.News[ newId=" + newId + " ]";
    }
}
